package com.ay277.htqoa.thread;

/**
 * Created by accp09 on 2016/12/26.
 */
public class threadTest {
    public static void main(String[] args) {
        Thread thread=new Thread(new thread2());
        thread.start();
        new thread1(thread).start();

    }
}
class thread1 extends Thread{
  Thread thread;

    public thread1(Thread thread) {
        this.thread = thread;
    }

    @Override
    public void run() {
        for(int i=1;i<=10;i++ ){
            System.out.println("Thread1："+i);
            if (i==5){
                try {
                    thread1.sleep(1000);
                    thread.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
         /*   synchronized ("abc"){
                System.out.println("Thread1："+i);
                "abc".notify();
                try {
                    "abc".wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }*/

        }
        super.run();
    }
}

class thread2 implements Runnable{

    @Override
    public void run() {
        for(int i=10;i>=1;i-- ){
            System.out.println("Thread2："+i);
            /*synchronized ("abc"){
                System.out.println("Thread2："+i);
                "abc".notify();
                try {
                    "abc".wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }*/

        }
    }
}